package example.file;

import java.io.File;
import java.io.FilenameFilter;

/**
 * Created by lenovo on 2016/11/4 0004.
 */
public class FindFileInDir {
    static FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.startsWith("b");
        }
    };

    public static void main(String[] args) {
        File dir = new File("C:");
        String[] children = dir.list(filter);
        if (children == null) {
            System.out.println("目录不存在或它不是一个目录");
        } else {
            for (String filename : children) {
                System.out.println(filename);
            }
        }
    }
}
